LeetCode 206: reverse linked list

Brute force solution: stack-based
Time complexity: O(n) 
Space complexity: O(n)

Three pointer approach:

       prev cur  next
null <-	1  2 -> 3 -> null

3 -> 2 -> 1 -> null

---------------------------------------------------------------
Doubly linked list

DNode: DNode<T> previous, T element, DNode<T> next

Special nodes: 

Header ---> DNode where: previous = null, element = null, next = first DNode in the doubly linked list

Trailer ---> DNode where: previous = the last DNode in list, element = null, next = null

When doubly linked list is empty:

Header:next <---> previous:Trailer


Position<T>: T getElement() ---> SNode implements Position

DNode<T> implements Position<T>

DList<T>:
int size();
boolean isEmpty();

DNode<T> first() throws EmptyListException
DNode<T> last() throws EmptyListException

DNode<T> next(DNode<T> d) throws BoundaryViolationException, InvalidPositionException
DNode<T> prev(DNode<T> d) throws BoundaryViolationExcepiton, InvalidPositionException

T remove(DNode<T> d) throws InvalidPositionException
T replace(DNode<T> d, T e) throws InvalidPositionException

DNode<T> insertFirst(T e)
DNode<T> insertLast(T e)

DNode<T> insertBefore(DNode<T> d, T e) throws InvalidPositionException
DNode<T> insertAfter(DNode<T> d, T e) throws InvalidPositionException

0 --- 1				3----	4
|					|

Header <---> 1 <---> 2 <---> 3 <---> Trailer


	---->	 ---->
1	<---  2  <---	3





















